package com.xfunc.utils;

public class Utils {


    static <T> UtilsTask<T> doAsync(final UtilsTask<T> task) {
        AppThreadUtils.getCachedPool().execute(task);
        return task;
    }


    public interface Consumer<T> {
        void accept(T t);
    }

    public interface Supplier<T> {
        T get();
    }

    public interface Func1<Ret, Par> {
        Ret call(Par param);
    }


    public abstract static class UtilsTask<Result> extends AppThreadUtils.SimpleThreadTask<Result> {

        private Consumer<Result> mConsumer;

        public UtilsTask(final Consumer<Result> consumer) {
            mConsumer = consumer;
        }

        @Override
        public void onSuccess(Result result) {
            if (mConsumer != null) {
                mConsumer.accept(result);
            }
        }
    }
}
